package com.weaver.drools.common.annotation;

import javax.annotation.Resource;

import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.weaver.drools.common.shiro.service.ShiroService;
@Component
@Aspect
public class ShiroSessionAspect {
	
	private static final Logger LOGGER = LoggerFactory.getLogger(ShiroSessionAspect.class);
	@Resource
	private ShiroService shiroService;
	@Resource
	private ShiroFilterFactoryBean shiroFilterFactoryBean;
	
	@After(("execution(* com.weaver.drools.business.sys..*.*(..)) && @annotation(shiroSession)"))
	public void doAfterAdvice(JoinPoint joinPoint, ShiroSession shiroSession) {  
		if(shiroService!=null) {
			shiroService.updatePermission(shiroFilterFactoryBean);
			LOGGER.info("=========================================shiro session过滤器链已更新=========================================");
		}
	}
}
